#!/bin/bash
#
# Copyright (c) 2016-2022 The Brenwill Workshop Ltd.
#
# packagePregenSpirvToolsHeaders - Packages Spirv-Tools headers to simplify building glslang
#
# macOS usage: ./packagePregenSpirvToolsHeaders
#

set -e

EXT_DIR=../External
SPV_TLS_BLD_DIR="${EXT_DIR}/glslang/External/spirv-tools/build"
TPLT_DIR=../Templates/spirv-tools
TPLT_BLD_DIR="${TPLT_DIR}/build"

# Ensure the SPIRV-Tools library is fully built
cd ".."
./fetchDependencies --build-spirv-tools --none
cd -  > /dev/null

echo Updating SPIRV-Tools template build directory
rm -rf "${TPLT_BLD_DIR}"
mkdir -p "${TPLT_BLD_DIR}"
cp -a "${SPV_TLS_BLD_DIR}/"*.h "${SPV_TLS_BLD_DIR}/"*.inc "${TPLT_BLD_DIR}"

echo Creating pregenerated SPIRV-Tools build.zip package
cd "${TPLT_DIR}"
rm -f build.zip
zip -qr build.zip build
rm -rf build/
cd -  > /dev/null

